cmake_minimum_required(VERSION 3.15)

set(projectName demo)

project(${projectName})

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-pthread")

include_directories(
  ${PROJECT_SOURCE_DIR}/../source/lc/inc ${PROJECT_SOURCE_DIR}/../source/jz/inc
  ${PROJECT_SOURCE_DIR}/../source/pub ${PROJECT_SOURCE_DIR}/../test/inc
  ${PROJECT_SOURCE_DIR}/../third/inc)

list(APPEND UT_SRC_FILES src/leetcode_test.cpp)
# src/jianzhi_test.cpp)

list(APPEND UT_EXE_FILES ut_leetcode_test)
# ut_jianzhi)

# for gcov
if(ENABLE_COVERAGE)
  message(STATUS "Use gcov for code coverage test")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
endif()

link_directories(${PROJECT_SOURCE_DIR}/../third/lib
                 ${PROJECT_SOURCE_DIR}/../output/lib)

add_compile_options(-g)

foreach(ut_exe ut_src IN ZIP_LISTS UT_EXE_FILES UT_SRC_FILES)
  message(STATUS "ut_src = ${ut_src}")
  message(STATUS "ut_exe = ${ut_exe}")

  add_executable(${ut_exe} ${ut_src})
  target_link_libraries(
    ${ut_exe}
    libgtest.a
    libgtest_main.a
    libgmock.a
    libgmock_main.a
    libmockcpp.a
    pthread
    lc)
    # jz)
endforeach()
